{include file='public/head'}
<style>
    .layui-table th{
        text-align: center;
    }
    td {
        text-align: center
    }
    .layui-form-checkbox{
        padding-left: 0px !important;
    }
</style>
<body>
<div class="x-body">
    <form class="layui-form" id='mainForm' method="post" action="changePrice">
        <table class="layui-table">
            <colgroup>
                <col style="width: 20px">
                <col style="width: 120px">
                <col style="width: 200px">
                <col style="width: 205px">
                <col>
                <col>
            </colgroup>
            <thead>
            <tr>
                <th>
                    <div class="header layui-form-checkbox" lay-skin="primary"><i class="layui-icon">&#xe605;</i></div>
                </th>
                <th>属性</th>
                <th colspan="2">选择操作方式</th>
                <th>数字</th>
                <th>百分比</th>
            </tr>
            <tr><th colspan="6">基本信息</th></tr>
            </thead>
            <tbody>
            <tr>
                <td>
                    <div class="layui-form-checkbox" lay-skin="primary" data-id='price'>
                        <i class="layui-icon">&#xe605;</i>
                    </div>
                </td>
                <td>默认价格</td>
                <td>
                    <input type="radio" name="type" value="type-1" title="增加" lay-filter="radio" checked >
                    <input type="radio" name="type" value="type-2" title="减少" lay-filter="radio">
                    <input type="hidden" id="type" name="price[type]" value="1">
                </td>
                <td>
                    <input type="radio" name="number" value="number-1" title="数字" lay-filter="radio"  checked>
                    <input type="radio" name="number" value="number-2" title="百分比" lay-filter="radio">
                    <input type="hidden" id="number" name='price[number]' value="1">
                </td>
                <td>
                    <input type="number" id="price" name='price[num]' autocomplete="off" step="0.01"
                           min="0" placeholder="请输入修改价格变动数字" class="layui-input">
                </td>
                <td>
                    <input type="number" id="percent" name='price[percent]' min="0" autocomplete="off"
                           placeholder="请输入修改价格变动百分比" class="layui-input">
                    <span style="position:absolute;top:20px;right:40px;">%</span>
                </td>
            </tr>
            <tr>
                <td>
                    <div class="layui-form-checkbox" lay-skin="primary" data-id='saleprice'>
                        <i class="layui-icon">&#xe605;</i>
                    </div>
                </td>
                <td>销售价格</td>
                <td>
                    <input type="radio" name="stype" value="stype-1" title="增加" lay-filter="radio"  checked>
                    <input type="radio" name="stype" value="stype-2" title="减少" lay-filter="radio" >
                    <input type="hidden" id="stype" name="saleprice[type]" value="1">
                </td>
                <td>
                    <input type="radio" name="snumber" value="snumber-1" title="数字" lay-filter="radio"  checked>
                    <input type="radio" name="snumber" value="snumber-2" title="百分比" lay-filter="radio" >
                    <input type="hidden" id="snumber" name="saleprice[number]" value="1">
                </td>
                <td>
                    <input type="number" id="sprice" name="saleprice[num]" autocomplete="off" step="0.01"
                           min="0" placeholder="请输入修改价格变动数字" class="layui-input">
                </td>
                <td>
                    <input type="number" id="spercent" name="saleprice[percent]" min="0" autocomplete="off"
                           placeholder="请输入修改价格变动百分比" class="layui-input">
                    <span style="position:absolute;top:20px;right:40px;">%</span>
                </td>
            </tr>
            <tr>
                <td>
                    <div class="layui-form-checkbox" lay-skin="primary" data-id='cost'>
                        <i class="layui-icon">&#xe605;</i>
                    </div>
                </td>
                <td>成本价</td>
                <td>
                    <input type="radio" name="ctype" value="ctype-1" title="增加" lay-filter="radio"  checked>
                    <input type="radio" name="ctype" value="ctype-2" title="减少" lay-filter="radio" >
                    <input type="hidden" id="ctype" name="cost[type]" value="1">
                </td>
                <td>
                    <input type="radio" name="cnumber" value="cnumber-1" title="数字" lay-filter="radio"  checked>
                    <input type="radio" name="cnumber" value="cnumber-2" title="百分比" lay-filter="radio" >
                    <input type="hidden" id="cnumber" name="cost[number]" value="1">
                </td>
                <td>
                    <input type="number" id="cprice" name="cost[num]" autocomplete="off" step="0.01"
                           min="0" placeholder="请输入修改价格变动数字" class="layui-input">
                </td>
                <td>
                    <input type="number" id="cpercent" name="cost[percent]" min="0" autocomplete="off"
                           placeholder="请输入修改价格变动百分比" class="layui-input">
                    <span style="position:absolute;top:20px;right:40px;">%</span>
                </td>
            </tr>
            <tr>
                <td>
                    <div class="layui-form-checkbox" lay-skin="primary" data-id='kucun'>
                        <i class="layui-icon">&#xe605;</i>
                    </div>
                </td>
                <td>库存</td>
                <td>
                    <input type="radio" name="ktype" value="ktype-1" title="增加" lay-filter="radio"  checked>
                    <input type="radio" name="ktype" value="ktype-2" title="减少" lay-filter="radio" >
                    <input type="hidden" id="ktype" name="kucun[type]" value="1">
                </td>
                <td>
                    <input type="radio" name="knumber" value="knumber-1" title="数字" lay-filter="radio"  checked>
                    <input type="radio" name="knumber" value="knumber-2" title="百分比" lay-filter="radio" >
                    <input type="hidden" id="knumber" name="kucun[number]" value="1">
                </td>
                <td>
                    <input type="number" id="kucun" name="kucun[num]" autocomplete="off"
                           min="0" placeholder="请输入修改库存变动数字" class="layui-input">
                </td>
                <td>
                    <input type="number" id="kpercent" name="kucun[percent]" min="0" autocomplete="off"
                           placeholder="请输入修改库存变动百分比" class="layui-input">
                    <span style="position:absolute;top:20px;right:40px;">%</span>
                </td>
            </tr>
            <tr><th colspan="6" style="background-color: #F2F2F2">变体信息</th></tr>
            <tr>
                <td>
                    <div class="layui-form-checkbox" lay-skin="primary" data-id='bprice'>
                        <i class="layui-icon">&#xe605;</i>
                    </div>
                </td>
                <td>默认价格</td>
                <td>
                    <input type="radio" name="btype" value="btype-1" title="增加" lay-filter="radio"  checked>
                    <input type="radio" name="btype" value="btype-2" title="减少" lay-filter="radio" >
                    <input type="hidden" id="btype" name="bprice[type]" value="1">
                </td>
                <td>
                    <input type="radio" name="bnumber" value="bnumber-1" title="数字" lay-filter="radio"  checked>
                    <input type="radio" name="bnumber" value="bnumber-2" title="百分比" lay-filter="radio" >
                    <input type="hidden" id="bnumber" name="bprice[number]" value="1">
                </td>
                <td>
                    <input type="number" id="bprice" name="bprice[num]" autocomplete="off" step="0.01"
                           min="0" placeholder="请输入修改价格变动数字" class="layui-input">
                </td>
                <td>
                    <input type="number" id="bpercent" name="bprice[percent]" min="0" autocomplete="off"
                           placeholder="请输入修改价格变动百分比" class="layui-input">
                    <span style="position:absolute;top:20px;right:40px;">%</span>
                </td>
            </tr>
            <tr>
                <td>
                    <div class="layui-form-checkbox" lay-skin="primary" data-id='bsaleprice'>
                        <i class="layui-icon">&#xe605;</i>
                    </div>
                </td>
                <td>销售价格</td>
                <td>
                    <input type="radio" name="bstype" value="bstype-1" title="增加" lay-filter="radio"  checked>
                    <input type="radio" name="bstype" value="bstype-2" title="减少" lay-filter="radio" >
                    <input type="hidden" id="bstype" name="bsaleprice[type]" value="1">
                </td>
                <td>
                    <input type="radio" name="bsnumber" value="bsnumber-1" title="数字" lay-filter="radio"  checked>
                    <input type="radio" name="bsnumber" value="bsnumber-2" title="百分比" lay-filter="radio" >
                    <input type="hidden" id="bsnumber" name="bsaleprice[number]" value="1">
                </td>
                <td>
                    <input type="number" id="bsaleprice" name="bsaleprice[num]" autocomplete="off" step="0.01"
                           min="0" placeholder="请输入修改价格变动数字" class="layui-input">
                </td>
                <td>
                    <input type="number" id="bspercent" name="bsaleprice[percent]" min="0" autocomplete="off"
                           placeholder="请输入修改价格变动百分比" class="layui-input">
                    <span style="position:absolute;top:20px;right:40px;">%</span>
                </td>
            </tr>
            <tr>
                <td>
                    <div class="layui-form-checkbox" lay-skin="primary" data-id='bcost'>
                        <i class="layui-icon">&#xe605;</i>
                    </div>
                </td>
                <td>成本价</td>
                <td>
                    <input type="radio" name="bctype" value="bctype-1" title="增加" lay-filter="radio"  checked>
                    <input type="radio" name="bctype" value="bctype-2" title="减少" lay-filter="radio" >
                    <input type="hidden" id="bctype" name="bcost[type]" value="1">
                </td>
                <td>
                    <input type="radio" name="bcnumber" value="bcnumber-1" title="数字" lay-filter="radio"  checked>
                    <input type="radio" name="bcnumber" value="bcnumber-2" title="百分比" lay-filter="radio" >
                    <input type="hidden" id="bcnumber" name="bcost[number]" value="1">
                </td>
                <td>
                    <input type="number" id="bcost" name="bcost[num]" autocomplete="off" step="0.01"
                           min="0" placeholder="请输入修改价格变动数字" class="layui-input">
                </td>
                <td>
                    <input type="number" id="bcpercent" name="bcost[percent]" min="0" autocomplete="off"
                           placeholder="请输入修改价格变动百分比" class="layui-input">
                    <span style="position:absolute;top:20px;right:40px;">%</span>
                </td>
            </tr>
            <tr>
                <td>
                    <div class="layui-form-checkbox" lay-skin="primary" data-id='bkucun'>
                        <i class="layui-icon">&#xe605;</i>
                    </div>
                </td>
                <td>变体库存</td>
                <td>
                    <input type="radio" name="bktype" value="bktype-1" title="增加" lay-filter="radio"  checked>
                    <input type="radio" name="bktype" value="bktype-2" title="减少" lay-filter="radio" >
                    <input type="hidden" id="bktype" name="bkucun[type]" value="1">
                </td>
                <td>
                    <input type="radio" name="bknumber" value="bknumber-1" title="数字" lay-filter="radio"  checked>
                    <input type="radio" name="bknumber" value="bknumber-2" title="百分比" lay-filter="radio" >
                    <input type="hidden" id="bknumber" name="bkucun[number]" value="1">
                </td>
                <td>
                    <input type="number" id="bkucun" name="bkucun[num]" autocomplete="off"
                           min="0" placeholder="请输入修改库存变动数字" class="layui-input">
                </td>
                <td>
                    <input type="number" id="bkpercent" name="bkucun[percent]" min="0" autocomplete="off"
                           placeholder="请输入修改库存变动百分比" class="layui-input">
                    <span style="position:absolute;top:20px;right:40px;">%</span>
                </td>
            </tr>
            </tbody>
        </table>



        <input type="hidden" id="proname" name="proname" value="{$Think.get.proname}">
        <input type="hidden" id="code" name="code" value="{$Think.get.code}">
        <input type="hidden" id="platform" name="platform" value="{$Think.get.platform}">
        <input type="hidden" id="lang" name="lang" value="{$Think.get.lanid}">
        <input type="hidden" id="audit" name="audit" value="{$Think.get.audit}">
        <input type="hidden" id="bname" name="bname" value="{$Think.get.bname}">
        <input type="hidden" id="guids" name="guids" value="">
        <input type="hidden" id="source" name="source" value="{$Think.get.source}">
        <input type="hidden" id="start" name="start" value="{$Think.get.start}">
        <input type="hidden" id="end" name="end" value="{$Think.get.end}">

        <button class="layui-btn" id="btn_save" type="button" style="display: none">提交</button>
    </form>
</div>
</body>
{include file='public/foot'}
<script>
    var layer = layui.layer;
    var form = layui.form;
    $("#guids").val(parent.$('#guid').val());
    form.on('radio(radio)', function (data) {
        var str = data.value;
        var arr = str.split("-");
        $("#"+arr[0]).val(arr[1]);
    });

    $('#btn_save').click(function () {
        var data = tableCheck.getData();
        if (data.length == 0) {
            layer.msg("请选择需要修改的选项");
            return false;
        }

        var formData = new FormData(document.getElementById("mainForm"));//表单id
        formData.append("choose",data);
        // 提交成功后样式修改
        $.ajax({
            url: '',
            type: 'POST',
            data: formData,
            async: false,
            cache: false,
            contentType: false,
            processData: false,
            success: function (data) {
                if (data.code == 0) {
                    layer.msg(data.msg);
                } else {
                    layer.msg(data.msg, {icon: 1, time: 500}, function () {
                        $("#reset").click();
                        x_admin_close();
                        parent.location.reload();
                    });
                }
            }
        });
    });
</script>